package cc.comac.saic.hkhy.jsrj.gj.inttools.parser;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import cc.comac.saic.hkhy.jsrj.gj.inttools.parser.config.ParserConfig;

/**
 * @author shisongyan
 * @date 2025/11/18
 */
public class Demo {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(ParserConfig.class);
        IntToolDataParser parser = context.getBean(IntToolDataParser.class);

        // 测试JSON数据
        String jsonData = "{\n" +
            "  \"project_id\": 255,\n" +
            "  \"req_model_id\": 414\n" +
            "}";
        ParseResult jsonResult = parser.parseData(jsonData);
        Object requirementItemId = jsonResult.getField("requirement_item_id");
        System.out.println("JSON解析结果: " + jsonResult.getExtractedData());

        // 测试XML数据
        String xmlData = "<?xml version=\"1.0\"?><user><name>李四</name><age>30</age><email>lisi@example.com</email></user>";
        ParseResult xmlResult = parser.parseData(xmlData);
        System.out.println("XML解析结果: " + xmlResult.getExtractedData());
    }
}
